package com.ccf.business.etl.model.neo;

import lombok.Data;
import org.springframework.util.CollectionUtils;

import java.util.HashSet;
import java.util.Set;

@Data
public class NeoPolygon {
    // 实体
    private Set<NeoNode> nodes;
    // 关系/事件
    private Set<NeoRelation> edges;

    public void addNode(NeoNode node){
        if (CollectionUtils.isEmpty(nodes)) {
            nodes = new HashSet<>();
        }

        if (node != null) {
            nodes.add(node);
        }
    }

    public void addEdge(NeoRelation relation){
        if (CollectionUtils.isEmpty(edges)) {
            edges = new HashSet<>();
        }

        if (relation != null) {
            edges.add(relation);
        }
    }

    public void addNodes(Set<NeoNode> nodeList){
        if (CollectionUtils.isEmpty(nodes)) {
            nodes = new HashSet<>();
        }

        if (!CollectionUtils.isEmpty(nodeList)){
            nodes.addAll(nodeList);
        }
    }

    public void addEdges(Set<NeoRelation> relationList){
        if (CollectionUtils.isEmpty(edges)) {
            edges = new HashSet<>();
        }

        if (!CollectionUtils.isEmpty(relationList)){
            edges.addAll(relationList);
        }
    }
}
